Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

高速なHasherを使う (SipHashのかわりに) #156

Merged
merged 2 commits into from
Jan 8, 2024

Conversation

ciscorn
Copy link
Member

@ciscorn ciscorn commented Jan 8, 2024

HashMap, IndexMap, etc. を多用する場面で、 Hasher を ahash に切り替える。

背景

Rust の HashMap / HashSet はデフォルトで SipHash-1-3 (std::hash::SipHash) というハッシュ関数を使う。SipHashはHashDos攻撃への耐性が高いためにデフォルトのHasherとして採用されている。しかし高い HashDos 耐性が必要なく、hashを多用する場面ではより軽量なHasherに切り替えることができる(切り替えることがしばしば行われる)。

  • ahash - それなりの HashDos 耐性があり、パフォーマンスもよい
    • rust-lang/hashbrown (Rustの現在のHashMap実装の元になった crate) のデフォルトのHasherは aHash なので、明示的にahashに切り替える代わりに、これを HashMap のdrop-in replacementとして使える。
  • fxhash
  • rust-lang/rustc-hash - rustc で使われている Hasher

@ciscorn ciscorn self-assigned this Jan 8, 2024
@ciscorn ciscorn force-pushed the use-faster-hasher branch from 21b52fa to 3efab29 Compare January 8, 2024 07:44
@ciscorn ciscorn force-pushed the use-faster-hasher branch from 3efab29 to fd3afb6 Compare January 8, 2024 07:46
Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files
Components Coverage Δ
GUI ∅ <ø> (∅)
Backend 76.10% <ø> (ø)
Libraries 86.34% <100.00%> (ø)

📢 Thoughts on this report? Let us know!

@ciscorn ciscorn merged commit 8429525 into minor-refactor-pipeline Jan 8, 2024
4 checks passed
@ciscorn ciscorn deleted the use-faster-hasher branch January 8, 2024 08:44
ciscorn added a commit that referenced this pull request Jan 9, 2024
## 変更内容

### #153 

#### 仮のTransformerで「とりあえず」の全頂点の変換処理を行う
- x-y 入れかえ処理を入れておく
    - これにともない GeoJSON, GeoPackage ドライバ内での x-y 入れかえは除去する
- CRSを WGS 84 にしておく処理も追加 #155

#### Gpkg, GeoJSON 周りのリファクタリング
- `nusamai-geojson` に "indexed" でないふつうのジオメトリをGeoJSON
Valueに変換する関数を追加(tiling2d sink で使う)。
    - #154 もこのPRにマージ
- Gpkg のバイナリジオメトリの構築で、 `Vec<u8>` でなく `std::io::Write` trait
を使う(`Vec<u8>`はWrite)。一時的なVecの生成も除去。

### その他

- Gpkg sink が、インメモリSQLiteを扱えていない(`:memory:` というファイルを作ってしまう)問題を修正
- SipHash → aHash #156
- Iterator::chain 除去 #157
- Noop Sink, Serde Sinkを走らせるだけのテストに GeoJSONとGPKG も追加
- `nusamai_citygml::object::Geometries` の名前を `GeometryStore`
に変更(ジオメトリのつめあわせであることを多少分かりやすく)
- `GeometryStore` にCRSの情報をもたせられるようにしておく(仮)
- その他細かい調整など
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant